package com.wzm.controller;

import com.wzm.domain.Move;
import com.wzm.domain.User;
import com.wzm.domain.UserMove;
import com.wzm.service.UserService;
import com.wzm.util.Ajaxresult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping
    public List<Move> findAll(){
        return userService.findAll();
    }

    @PostMapping("/buy")
    public Ajaxresult buyById(@RequestBody UserMove userMove){
            return userService.buyById(userMove);
    }

    @PutMapping
    public Ajaxresult addUser(@RequestBody User user){
        return userService.addUser(user);
    }

    @GetMapping("/watch/{id}")
    public Ajaxresult watch(@PathVariable Long id){
        return userService.watch(id);
    }
}
